<SCRIPT type="text/javascript">
function submitForm(){
		$("#mainForm").submit();
}
function onradio(val,type){
	var path = "";
	if(type == "string"){
		if(val == "equal"){
			path = "<input name = 'hlhtmlstart' value = '' id = 'hlhtmlstart' maxlength='255' class='span3 required' required=''/><i class='inputip'>*</i>";
		}else if (val == "unequal"){
			path = "<input name = 'hlhtmlend' value = '' id = 'hlhtmlend' maxlength='255' class='span3 required' required=''/><i class='inputip'>*</i>";
		}
	}else if(type == "number"){
		if(val == "equal"){
			path = "<input name = 'hlhtmlstart' value = '' id = 'hlhtmlstart' maxlength='255' class='span3 required number' required=''/><i class='inputip'>*</i>";
		}else if (val == "scope"){
			path = "<input name = 'hlhtmlstart' value = '0' id = 'hlhtmlstart' maxlength='255' class='span3 number'/><br><br>"+
			"<input name = 'hlhtmlend' value = '' id = 'hlhtmlend' maxlength='255' class='span3 number'/>";
		}else if (val == "unequal"){
			path = "<input name = 'hlhtmlend' value = '' id = 'hlhtmlend' maxlength='255' class='span3 required  number' required=''/><i class='inputip'>*</i>";
		}
	}else if (type == "dtimes"){
		if(val == "equal"){
			path = "<input name = 'hlhtmlstart' value = '' id = 'hlhtmlstart' maxlength='255' class='span3 required startdate' required='' readOnly='readonly'/><i class='inputip'>*</i>";
		}else if (val == "scope"){
			path = "<input name = 'hlhtmlstart' value = '' id = 'hlhtmlstart' maxlength='255' class=' span3 startdate'/><br><br>"+
			"<input name = 'hlhtmlend' value = '' id = 'hlhtmlend' maxlength='255' class='span3 startdate'/>";
		}else if (val == "unequal"){
			path = "<input name = 'hlhtmlend' value = '' id = 'hlhtmlend' maxlength='255' class='span3 required startdate' required='' readOnly='readonly'/><i class='inputip'>*</i>";
		}
	}else if (type == "colors"){
		if(val == "equal"){
			path = "<input name = 'hlhtmlstart' value = '' id = 'hlhtmlstart' maxlength='255' class='span3 required' required=''/><i class='inputip'>*</i>";
		}else if (val == "scope"){
			path = "<input name = 'hlhtmlstart' value = '' id = 'hlhtmlstart' maxlength='255' class='span3'/><br><br>"+
			"<input name = 'hlhtmlend' value = '' id = 'hlhtmlend' maxlength='255' class='span3'/>";
		}else if (val == "unequal"){
			path = "<input name = 'hlhtmlend' value = '' id = 'hlhtmlend' maxlength='255' class='span3 required' required=''/><i class='inputip'>*</i>";
		}
	}
	$("#div_type").html(path);
	$(".startdate").datepicker({
		nextText: "&gt;",
		prevText: "&lt;",
		showOn:"both",
		buttonImageOnly: true,
		buttonImage: "/assets/images/icon-calendar.gif",
		dateFormat:"yy-MM-dd",
		monthNames:['01','02','03','04','05','06','07','08','09','10','11','12']
	});
	if(type == "colors"){
		//绑定颜色选择器
		$("#hlhtmlstart").colorpicker({
			fillcolor:true,
    		target:$("#hlhtmlstart"),
    		success:function(){}
		});
		$("#hlhtmlend").colorpicker({
			fillcolor:true,
    		target:$("#hlhtmlend"),
    		success:function(){}
		});
	}
}
//页面初始化时候将时间控件和颜色选择器绑定到对应的文本框上（新增的时候绑定不到，主要用于修改时）
$(document).ready(function(){
	var type = "${properties.type}";
	$(".startdate").datepicker({
		nextText: "&gt;",
		prevText: "&lt;",
		showOn:"both",
		buttonImageOnly: true,
		buttonImage: "/assets/images/icon-calendar.gif",
		dateFormat:"yy-MM-dd",
		monthNames:['01','02','03','04','05','06','07','08','09','10','11','12']
	});
	if(type == "colors"){
		//绑定颜色选择器
		$("#hlhtmlstart").colorpicker({
			fillcolor:true,
    		target:$("#hlhtmlstart"),
    		success:function(){}
		});
		$("#hlhtmlend").colorpicker({
			fillcolor:true,
    		target:$("#hlhtmlend"),
    		success:function(){}
		});
	}	
});
</SCRIPT>
<div class="artCon" style="width:480px;">
	<div class="middleArt">
	<form class="form-horizontal" id="mainForm" data-toggle="form"  method="post"
		<#if type ??>
			action="/${orgi}/manage/task/searchsettingaddo/${type!''}.html" 
		<#else>
			action="/${orgi}/manage/task/warn/searchsettingaddof.html" 
		</#if>>
		<div class="artMain"  style="width:480px;">
			<div class="mainCenter"  style="width:480px;">
				<fieldset class="control-group">
					<label class="control-label" for="name">阀值类型：</label>
					<input type="hidden" name ="sitename" value="${properties.name!''}">
					<div class="controls">
						<#if properties.type ?? && properties.type == "string">
							<input type="radio" name="hlsnippets" value="equal" id="a" onclick="onradio('equal','${properties.type}')" <#if search.hlsnippets?? && search.hlsnippets == "equal">checked="checked"</#if>/><label for="a">等于</label>
							<input type="radio" name="hlsnippets" value="unequal" id="c" onclick="onradio('unequal','${properties.type}')" <#if search.hlsnippets?? && search.hlsnippets == "unequal">checked="checked"</#if>/><label for="c">不等于</label>
							<div id = "div_type">
								<#if search ?? && search.hlhtmlstart ??>
									<input name = 'hlhtmlstart' value = '${search.hlhtmlstart}' id = 'hlhtmlstart' maxlength='255' class='span3 required' required=''/><br><br>
								</#if>
								<#if search ?? && search.hlhtmlend ??>
									<input name = 'hlhtmlend' value = '${search.hlhtmlend}' id = 'hlhtmlend' maxlength='255' class='span3 required' required=''/>
								</#if>
							</div>
						<#elseif properties.type ?? && properties.type == "number">
							<input type="radio" name="hlsnippets" value="equal" id="a" onclick="onradio('equal','${properties.type}')" <#if search.hlsnippets?? && search.hlsnippets == "equal">checked="checked"</#if>/><label for="a">等于</label>
							<input type="radio" name="hlsnippets" value="scope" id="b" onclick="onradio('scope','${properties.type}')" <#if search.hlsnippets?? && search.hlsnippets == "scope">checked="checked"</#if>/><label for="b">范围</label>
							<input type="radio" name="hlsnippets" value="unequal" id="c" onclick="onradio('unequal','${properties.type}')" <#if search.hlsnippets?? && search.hlsnippets == "unequal">checked="checked"</#if>/><label for="c">不等于</label>
							<i class="inputip">*</i><br><br>
							<div id = "div_type">
								<#if search ?? && search.hlhtmlstart ??>
									<input name = 'hlhtmlstart' value = '${search.hlhtmlstart}' id = 'hlhtmlstart' maxlength='255' class='span3 required number' required=''/><br><br>
								</#if>
								<#if search ?? && search.hlhtmlend ??>
									<input name = 'hlhtmlend' value = '${search.hlhtmlend}' id = 'hlhtmlend' maxlength='255' class='span3 required  number' required=''/>
								</#if> 
							</div>
						<#elseif properties.type ?? && properties.type == "dtimes">
							<input type="radio" name="hlsnippets" value="equal" id="a" onclick="onradio('equal','${properties.type}')" <#if search.hlsnippets?? && search.hlsnippets == "equal">checked="checked"</#if>/><label for="a">等于</label>
							<input type="radio" name="hlsnippets" value="scope" id="b" onclick="onradio('scope','${properties.type}')" <#if search.hlsnippets?? && search.hlsnippets == "scope">checked="checked"</#if>/><label for="b">范围</label>
							<input type="radio" name="hlsnippets" value="unequal" id="c" onclick="onradio('unequal','${properties.type}')" <#if search.hlsnippets?? && search.hlsnippets == "unequal">checked="checked"</#if>/><label for="c">不等于</label>
							<i class="inputip">*</i><br><br>
							<div id = "div_type">
								<#if search ?? && search.hlhtmlstart ??>
									<input name = 'hlhtmlstart' value = '${search.hlhtmlstart}' id = 'hlhtmlstart' maxlength='255' class='span3 required startdate' required='' readOnly='readonly'/><br><br>
								</#if>
								<#if search ?? && search.hlhtmlend ??>
									<input name = 'hlhtmlend' value = '${search.hlhtmlend}' id = 'hlhtmlend' maxlength='255' class='span3 required startdate' required='' readOnly='readonly'/>
								</#if>
							</div>
						<#elseif properties.type ?? && properties.type == "colors">
							<input type="radio" name="hlsnippets" value="equal" id="a" onclick="onradio('equal','${properties.type}')" <#if search.hlsnippets?? && search.hlsnippets == "equal">checked="checked"</#if>/><label for="a">等于</label>
							<input type="radio" name="hlsnippets" value="scope" id="b" onclick="onradio('scope','${properties.type}')" <#if search.hlsnippets?? && search.hlsnippets == "scope">checked="checked"</#if>/><label for="b">范围</label>
							<input type="radio" name="hlsnippets" value="unequal" id="c" onclick="onradio('unequal','${properties.type}')" <#if search.hlsnippets?? && search.hlsnippets == "unequal">checked="checked"</#if>/><label for="c">不等于</label>
							<i class="inputip">*</i><br><br>
							<div id = "div_type">
								<#if search ?? && search.hlhtmlstart ??>
									<input name = 'hlhtmlstart' value = '${search.hlhtmlstart}' id = 'hlhtmlstart' maxlength='255' class='span3 required' required=''/><br><br>
								</#if>
								<#if search ?? && search.hlhtmlend ??>
									<input name = 'hlhtmlend' value = '${search.hlhtmlend}' id = 'hlhtmlend' maxlength='255' class='span3 required' required=''/>
								</#if>
							</div>
						<#elseif properties.type ?? && properties.type == "blean">
							<input type="radio" name="hlsnippets" value="true" id="a" <#if search.hlsnippets?? && search.hlsnippets == "true">checked="checked"</#if>/><label for="a">是</label>
							<input type="radio" name="hlsnippets" value="false" id="b" <#if search.hlsnippets?? && search.hlsnippets == "false">checked="checked"</#if>/><label for="b">否</label>
							<i class="inputip">*</i>
						</#if>
					</div>
				</fieldset>	 
				
				<fieldset class="control-group">
					<label class="control-label" for="name">预警级别：</label>
					<div class="controls">
						<select name ="searchtype">
							<option value="endanger" <#if search.searchtype?? && search.searchtype == "endanger">selected="selected"</#if>>危急</option>
							<option value="urgent" <#if search.searchtype?? && search.searchtype == "urgent">selected="selected"</#if>>紧急</option>
							<option value="warn" <#if search.searchtype?? && search.searchtype == "warn">selected="selected"</#if>>警告</option>
							<option value="prompt" <#if search.searchtype?? && search.searchtype == "prompt">selected="selected"</#if>>提示</option>
						</select>
					</div> 
				</fieldset>
				
				<fieldset class="control-group">
					<#if site ??> 
					<label class="control-label" for="name">预警方式：</label>
					<div class="controls">
						<#if search.siteemail?? && search.siteemail == "eml">
							<label for="aa"><input type="checkbox" name="siteemail" value="eml" id="aa" checked="checked">邮件</label>
							<label for="bb"><input type="checkbox" name="siteemail" value="sms" id="bb">短信</label>
						<#elseif search.siteemail?? && search.siteemail == "sms">
							<label for="aa"><input type="checkbox" name="siteemail" value="eml" id="aa">邮件</label>
							<label for="bb"><input type="checkbox" name="siteemail" value="sms" id="bb" checked="checked">短信</label>
						<#elseif search.siteemail?? && search.siteemail == "eml,sms">
							<label for="aa"><input type="checkbox" name="siteemail" value="eml" id="aa" checked="checked">邮件</label>
							<label for="bb"><input type="checkbox" name="siteemail" value="sms" id="bb" checked="checked">短信</label>
						<#else>
							<label for="aa"><input type="checkbox" name="siteemail" value="eml" id="aa">邮件</label>
							<label for="bb"><input type="checkbox" name="siteemail" value="sms" id="bb">短信</label>
						</#if>
						<!-- <label for="cc"><input type="checkbox" name="siteemail" value="msg" id="cc">内部消息</label> -->
					</div>
					</#if>
				</fieldset>
				
				<fieldset class="control-group">
					<label class="control-label" for="name">预警服务器：</label>
					<div class="controls">
						<#if clusterList ??>
							<#list clusterList as cluster>
								<label for="${cluster.id}">
									<input type="checkbox" name="r3cloudserver" value="${cluster.serverhost}" id="${cluster.id}">${cluster.serverhost}
								</label>
							</#list>
						</#if>
					</div>
				</fieldset>
				
				<fieldset class="control-group">
					<label class="control-label" for="name">预警频率：</label>
					<div class="controls">
						<select name ="sitedesc">
							<option value="minute" <#if search.sitedesc?? && search.sitedesc == "minute">selected="selected"</#if>>分钟</option>
							<option value="house" <#if search.sitedesc?? && search.sitedesc == "house">selected="selected"</#if>>小时</option>
							<option value="day" <#if search.sitedesc?? && search.sitedesc == "day">selected="selected"</#if>>天</option>
							<option value="month" <#if search.sitedesc?? && search.sitedesc == "month">selected="selected"</#if>>月</option>
							<option value="year" <#if search.sitedesc?? && search.sitedesc == "year">selected="selected"</#if>>年</option>
						</select>
					</div> 
				</fieldset>
				
				<fieldset class="control-group">
					<label class="control-label" for="name">预警次数：</label>
					<div class="controls">
						<input name = 'startdelay' value = '${search.startdelay}' id = 'startdelay' maxlength='255' class='span3 required number' required=''/><br><br>
					</div> 
				</fieldset>
				<#if type ??>
				<fieldset class="control-group">
					<label class="control-label" for="name">是否预警：</label>
					<div class="controls">
						<input type="radio" name="spellcheck" value="1" id="1" <#if search.spellcheck?? && search.spellcheck == "1">checked="checked"</#if>/><label for="1">是</label>
						<input type="radio" name="spellcheck" value="0" id="0" <#if search.spellcheck?? && search.spellcheck == "0">checked="checked"</#if>/><label for="0">否</label>
						<i class="inputip">*</i>
					</div> 
				</fieldset>
				</#if>
			</div>
			<div class="bottomBg"  style="width:480px;">
				<div class="btnWrap">
					<input type="button" onclick="submitForm()" class="subButtonStyle" value="确认"/>
					<input type="button" onclick="closeR3ArtDialog()" class="cancelButtonStyle" value="取消"/>
				</div>
			</div>
		</div>
	</form>
	</div>
</div>
